<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>NoteBook</title>
<link rel="stylesheet" type="text/css" href="/css/style.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script src="/js/action.js"></script>
<script>
function addTag()
{
	favoritenum = $("#favnum").val();
	$("a[@name="+blogid+"] em").html(favoritenum);
	$("#submittag").click(function ()
	{
		
		tagtxt = $("#tagtext").val();
		$.ajax  
		({
			type: "get",
			url: serverpath+"submit",
			data: "act=addtag&blogid="+blogid+"&tagtxt="+tagtxt,
			timeout: ajaxtimeout,
			beforeSend:function()
			{
				loading(true);
			},
			success:function(text)
			{
				hideFloat("popiframe");
					
			},
			error:function()
			{},
			complate:function()
			{}
		})
	})
}
$(document).ready(function()
{
	$("#account").click(function()
	{
		showDiv("account",300,200,"个人资料",null,null)
		return false;
	})
	
	$("a[@id=favorite]").click(function()
	{
		blogid = $(this).attr("name");
		showDiv("favorite",350,230,"关注","addTag()","&blogid="+blogid)
		return false;
	})
	$(".button #submit").click(function()
	{
		contents = $("#content").val();
		if(contents == "")
		{
			$("#errormeg").html("请填写内容");
			return false;
		}
		if(contents.length>450)
		{
			$("#errormeg").html("内容长度不能超过450个字符");
			return false;
		}
	})
	$("#content").keydown(function(e)
	{
		leavenum = 450 - $("#content").val().length;
		$("#errormeg").html("您还能输入"+leavenum+"个字符");
		if(leavenum == 0)
		{
			if(e.keyCode != 8 && e.keyCode != 46)
			{
				return false;
			}
		}
	})
})
</script>
</head>
<body>
<div class="warp">
	<div class="header">
		{%if member %}
		<div class="topbar">
		<a href="/myfavor" >我的关注</a> <a href="#" id="account">个人设置</a> <a href="{{logouturl}}">退出</a></div>
		{%endif%}
		{%if returnurl %}
		<div class="navtext"><a href='{{returnurl}}'>返回</a></div>
		{%endif%}
		{%if topblog %}
		
		<div class="block topblock">
		<h4>评论此文</h4>
		<ul>
		<li class="avatar">
			<img src="/avatar?imgid={{topblog.author.key}}" width=48 height=48>	
		</li>
		
		<li class="content">
		<span class="text">
		<a href="#">{{topblog.author.nickname}}</a>
		{{topblog.content}}</span>
		<span class="time">{{topblog.createtime|datetz:"Y-m-d H:i:s"}}
		{%if isadmin%}
		<a href="/submit?act=delete&blogid={{topblog.key}}">delete</a>
		{%endif%}
		</span>
		</li>
		</ul>
		<div class="clear"></div>
		</div>
		{% endif %}
		{%if member %}
		<div class="submit">
			
			<form action="/submit" method="post">
			<div>我说：</div>
			<div><input type="checkbox" value="1" name="noname">匿名</div>
			<div class="textarea"><textarea name="content" id="content"></textarea></div>
			<div class="button"><button type="submit" id="submit">发表</button></div>
			{%if topblog %}
				<input type="hidden" name="topblogkey" value="{{topblog.key}}">
			{%endif%}
			</form>
		</div>
		<div class="errormeg" id="errormeg"></div>
		<div style="width:700px;float:left">您可以用注册邮箱发送邮件到send@cdelzone.appspotmail.com ,邮件的主题将被当作一条新的留言发表</div>
		{%else%}
		如果您有一个Google的帐号 您可以直接	<a href="{{loginurl}}" >登录</a> ，没有的话可以先 <a  target="_blank" href="https://www.google.com/accounts/NewAccount?continue=http%3A%2F%2Fcdelzone.appspot.com%2F_ah%2Flogin%3Fcontinue%3Dhttp%3A%2F%2Fcdelzone.appspot.com%2F&service=ah&ltmpl=gm&sig=cc98a349104ee6c13618362e96b2fc16">注册</a> 
		{%endif%}
		
		<div class="clear"></div>
	</div>
	
	
	<div class="blocklist">
	{%for blog in blogs %}
	<div class="block">
		<ul>
		<li class="avatar">
		{%ifequal blog.noname 0 %}
			<img src="/avatar?imgid={{blog.author.key}}" width=48 height=48>
		{%else%}
			<img src="{{noname.avatar}}" width=48 height=48>
		{%endifequal%}
		</li>
		
		<li class="content">
		<span class="text">
		{%ifequal blog.noname 0 %}
		<a href="/u/{{blog.author.nickname}}">{{blog.author.nickname}}</a>
		{%else%}
		<a href="#">{{noname.name}}</a>
		{%endifequal%}
		{{blog.content}}</span>
		<span class="time">{{blog.createtime|datetz:"Y-m-d H:i:s"}}
		
		{%if isadmin%}
		<a href="/submit?act=delete&blogid={{blog.key}}">delete</a>
		{%endif%}
		</span>
		<span class="comment">[<a id="favorite" name="{{blog.key}}" >关注(<em>{{blog.favoritenum}}</em>)</a>] [<a href="?top={{blog.key}}">评论(<em>{{blog.commentnum}}</em>)</a>]</span>
		</li>
		
		</ul>
		<div class="clear"></div>
	</div>
	{%endfor%}
	</div>
</div>
</body>
</html>
